<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>事件处理</title>
	</head>
	<body>
		<div id="app">
			<button v-on:click="counter += 1">Add 1</button>
			<p>he button above has been clicked {{ counter }} times</p>
			<button v-on:click="greet">Greet</button>
			<button v-on:click="say('what')">Say what</button>
			<button v-on:click="warn('Form cannot be submitted yet', $event)">Submit</button>
		</div>
	</body>
	<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
	<script>
		var vm = new Vue({
			el:"#app",
			data:{
				counter:0,
			},
			methods:{
				greet:function(event){
					alert('hello alert');
					if(event){
						alert(event.target.tagName);
					}
				},
				say:function(msg){
					alert(msg);
				},
				warn:function(msg,event){
					if(event){
						event.preventDefault();
					}
					alert(msg);
				}
			}
		})
	</script>
</html>